import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 强仔
 * Date: 2022-08-30
 * Time: 20:37
 */
public class Main {

    // 2. 简单错误记录
    // nice 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        List<String> list = new ArrayList<>();
        String fir = sc.nextLine();
        list.add(fir);

        while (sc.hasNextLine()){
            String s = sc.nextLine();
            if(list.get(0).equals(s) || s.equals("")){
                break;
            }
            list.add(s);
        }


        Map<String, Integer> map = new HashMap<>();
        int size = list.size();

        List<String> newList = new ArrayList<>();

        for (String s : list) {
            String[] strings = s.split(" ");
            String rowNum = strings[1];
            String fileName = subFileName(strings[0]);

            String file = fileName + " " + rowNum;

            if (map.get(file) == null) {
                newList.add(file);
            }

            map.put(file, map.getOrDefault(file, 0) + 1);
        }


        int newSize = newList.size();
        for (int i = newSize < 8 ? 0 : newSize - 8; i < newSize; i++) {
            String file = newList.get(i);
            int val = map.get(file);
            System.out.println(file + " " + val);
        }

    }

    public static String subFileName(String absolute){
        int index = absolute.lastIndexOf('\\');
        int len = absolute.length();

        String res = null;
        if(len - index <= 16){
            res = absolute.substring(index + 1);
        } else {
            res = absolute.substring(len - 16);
        }

        return res;
    }
}
